using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class CatalogMap : EntityTypeConfiguration<Catalog>
    {
        public CatalogMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Description)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Catalog");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Speciality_id).HasColumnName("Speciality_id");
            this.Property(t => t.Description).HasColumnName("Description");

            // Relationships
            this.HasRequired(t => t.Specialty)
                .WithMany(t => t.Catalogs)
                .HasForeignKey(d => d.Speciality_id);

        }
    }
}
